<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: hanfei
  Date: 18/7/19
  Time: 下午4:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="${allServerPath}static/layui/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${allServerPath}static/layui/css/style.css">
    <link rel="stylesheet" href="${allServerPath}static/layui/css/icon.css">
    <link rel="stylesheet" href="${allServerPath}static/layui/css/public.css">
</head>
<body style="background-color: #f0f2f5;" class="childrenBody">
<div class="layui-fluid wuli-main">
    <div class="layui-row">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>编辑订单</legend>
        </fieldset>
    </div>
    <form class="layui-form wuli-jiaofei-top" id="reportForm">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">订单状态</label>

                    <div class="layui-input-inline">
                        <select id="orderStatus" name="orderStatus" lay-filter="orderStatus">
                            <option value=""></option>
                            <option value="0">未支付</option>
                            <option value="1">支付中</option>
                            <option value="2">已支付</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">支付时间</label>

                    <div class="layui-input-inline">
                        <input type="text" id="payTime" name="payTime" autocomplete="off"
                               class="layui-input"
                               value='<fmt:formatDate value="${order.payDatetime}" pattern="yyyy-MM-dd HH:mm:ss"/>'>
                    </div>
                </div>
            </div>

            <div class="layui-row wuli-jiaofei" style="text-align: center">
                <button name="btnSave" type="button" class="layui-btn layui-btn-normal">保存</button>
            </div>
            <input type="hidden" name="id" value="${order.id}">
    </form>
</div>
<script src="${allServerPath}static/layui/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['layer', 'form', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , laydate = layui.laydate
            , $ = layui.$;

        laydate.render({
            elem: '#payTime',
            type: 'datetime'
        });

        var status = '${order.orderStatus}';
        if (null != status) {
            $("#orderStatus").val(status);
            form.render("orderStatus");
        }


        $("button[name='btnSave']").click(function () {
            $.ajax({
                type: 'post',
                url: '${allServerPath}web/order/save.htmls',
                data: $("#reportForm").serialize(),
                dataType: 'JSON',
                success: function (data) {
                    if (data.success) {
                        layer.msg("保存成功.");
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    } else {
                        layer.msg("保存失败,请稍后重试.");
                    }
                },
                error: function (msg) {
                    layer.msg("保存失败.");
                }
            });
        });


    });
</script>
</body>
</html>
